﻿@{
    ViewBag.Title = "Article Search";
}

@section scripts {
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Custom/ArticleJS.js")" type="text/javascript"></script>
}

@section get_search_element{
<script type="text/javascript">
    var searchWord = '@Session["searchWord"]';
</script>
}

<h1>Seach Articles</h1>

@using (Ajax.BeginForm("Search", "Home", 
    new AjaxOptions {
     InsertionMode=InsertionMode.Replace,
     HttpMethod="GET",
     OnFailure="searchFailed",     
     LoadingElementId="ajax-loader",
     UpdateTargetId="searchresults",
     OnSuccess = "showTable",               
}))
{
    <input type="text" name="q" required="required"/>
    <input type="submit" id="searchButton" value="Search" />
    <img id="ajax-loader" 
         src="@Url.Content("~/Images/ajax-loader.gif")" 
         style="display:none"/>
}
<table id="buttonTable" style="display: none"><tr><td>
@using (Ajax.BeginForm("First", "Home", 
    new AjaxOptions {
     InsertionMode=InsertionMode.Replace,
     HttpMethod="GET",
     OnFailure="searchFailed",
     UpdateTargetId="searchresults",
     OnSuccess = "greenHighlight",    
}))
{
    <button type="submit" value="First"><img src="~/Images/resultset_first.png" /></button>
}
</td><td>
@using (Ajax.BeginForm("Previous", "Home", 
    new AjaxOptions {
     InsertionMode=InsertionMode.Replace,
     HttpMethod="GET",
     OnFailure="searchFailed",
     UpdateTargetId="searchresults",
     OnSuccess = "greenHighlight",                 
}))
{
    <button type="submit" value="Previous"><img src="~/Images/resultset_previous.png" /></button>
}
</td><td>
@using (Ajax.BeginForm("Next", "Home", 
    new AjaxOptions {
     InsertionMode=InsertionMode.Replace,
     HttpMethod="GET",
     OnFailure="searchFailed",
     UpdateTargetId="searchresults",
     OnSuccess = "greenHighlight",                
}))
{
    <button type="submit" value="Next"><img src="~/Images/resultset_next.png" /></button>
}
    </td><td>
@using (Ajax.BeginForm("Last", "Home", 
    new AjaxOptions {
     InsertionMode=InsertionMode.Replace,
     HttpMethod="GET",
     OnFailure="searchFailed",
     UpdateTargetId="searchresults",
     OnSuccess = "greenHighlight",                 
}))
{
    <button type="submit" value="Last"><img src="~/Images/resultset_last.png" /></button>
}
</td>
    <td><button type="submit" value="Up" class="up"><img src="~/Images/resultset_up.png" /></button></td>
    <td><button type="submit" value="Down" class="down"><img src="~/Images/resultset_down.png" /></button></td>
</tr></table>
<br />
<div id="searchresults">
    
</div>

